import request from '@/utils/request'

const app_api = '/platform/min_app/index/'

// 获取创建表单
export function getAppCreateForm() {
  return request({
    url: app_api + 'create',
    method: 'GET'
  })
}

// 获取编辑表单
export function getAppEditForm(id) {
  return request({
    url: app_api + id + '/edit',
    method: 'GET'
  })
}

// 获取公众号通信

export function getAppMessage(plaid) {
  return request({
    url: app_api + 'getAppMessage',
    data: { plaid },
    method: 'POST'
  })
}

export function editAppMessage(plaid, formData) {
  return request({
    url: app_api + 'editAppMessage',
    data: { plaid, formData },
    method: 'POST'
  })
}

// 获取应用小程序表单
export function getAppForm(plaid = 0, addon_name = '') {
  return request({
    url: app_api + 'getAppForm',
    method: 'POST',
    data: { plaid, addon_name }
  })
}

// 获取应用小程序表单
export function getAppSettingForm(plaid = 0, addon_name = '') {
  return request({
    url: app_api + 'getAppSettingForm',
    method: 'POST',
    data: { plaid, addon_name }
  })
}

// 获取默认应用
export function getDefaultApp(plaid = 0, appid = 0) {
  return request({
    url: app_api + 'getDefaultApp',
    method: 'POST',
    data: { plaid, appid }
  })
}

export function getAddonsOption(plaid = 0) {
  return request({
    url: app_api + 'getAddonsOption',
    method: 'POST',
    data: { plaid }
  })
}

export function getAddonAppOption(plaid = 0, search = '') {
  return request({
    url: app_api + 'getAddonAppOption',
    method: 'POST',
    data: { plaid, search }
  })
}

// 切换默认小程序
export function changeDefaultApp(appid) {
  return request({
    url: app_api + 'changeDefaultApp',
    method: 'POST',
    data: { appid }
  })
}

// 删除小程序
export function deleteApp(appid) {
  return request({
    url: app_api + 'deleteApp',
    method: 'POST',
    data: { appid }
  })
}
